(function($){
    $(document.body).ready(function(){
        $.jgrid.no_legacy_api = true;
        $.jgrid.useJSON = true;
        var MAINTENANCE_TABLE="grid";
    
        var sfCllGrid = $("#"+MAINTENANCE_TABLE).jqGrid({
            url:AJAX_CORE_URL+"&operation=parents",
            datatype: "json",
            colNames:['CODIGO','NOMBRES', 'APELLIDOS'],
            colModel:[
            {
                name:'CODIGO',
                index:'ID',
                formatter: 'link'
            },
            {
                name:'NOMBRE_A',
                index:'NOMBRE_A',
                formatter: 'link'
            },
            {
                name:'APELLIDO_A',
                index:'APELLIDO_A',
                formatter: 'link'
            }
            ],
            autowidth: true,
            height:"100%",
            rowNum:10,
            pager: '#paginador',
            sortname: 'ID',
            viewrecords: true,
            sortorder: "desc",
            caption:"Listado",
            mtype: "POST",
            rowList:[10,20,30],
            gridview : true,
            onSelectRow:function(id){
                $("#IDP").val(id);
                doSubmit("operation=edit");
            }
        });

        $("#"+MAINTENANCE_TABLE).jqGrid('navGrid','#paginador',{
            edit:false,
            add:false,
            del:false,
            search:false,
            refresh:false
        });
				
        $("#"+MAINTENANCE_TABLE).jqGrid('navButtonAdd',"#paginador",
        {
            caption:"Busqueda",
            title:"Busqueda",
            buttonicon :'ui-icon-pin-s',
            onClickButton:function(){
                sfCllGrid[0].toggleToolbar()
            }
        });
				
        $("#"+MAINTENANCE_TABLE).jqGrid('navButtonAdd',"#paginador",
        {
            caption:"Restaurar",
            title:"Restrar Registros",
            buttonicon :'ui-icon-refresh',
            onClickButton:function(){
                sfCllGrid[0].clearToolbar()
            }
        });
        $("#"+MAINTENANCE_TABLE).jqGrid('filterToolbar');
    });
})(jQuery);
